import { DataSource } from "typeorm";
import type { DataSourceOptions } from "typeorm";
import { entities } from "./entities";

const {
    MYSQL_HOST: host,
    MYSQL_PORT: port,
    MYSQL_USER: username,
    MYSQL_PASSWORD: password,
    MYSQL_DATABASE: database,
} = Bun.env;

export const AppDataSource = new DataSource({
    type: "mysql",
    host,
    port: Number(port),
    username,
    password,
    database,
    entities,
    synchronize: true,
    logging: true,
} as DataSourceOptions);
